﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HANS_BackStageWeb.Common
{
    public class BaseController : Controller
    {
        // GET: Base
        #region ActionResult 
        public JsonResult JsonAllowGet(object data)
        {
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        #endregion

        /// <summary>
        /// 获取文件实际地址
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="fileCategory">文件分类</param>
        /// <returns>文件实际地址</returns>
        protected virtual string GetPhysicalPath(string fileName, string filePath)
        {
            return Path.Combine(HttpContext.Server.MapPath(filePath),
                               Path.GetFileName(fileName));
        }

        /// <summary>
        /// 获取文件相对地址
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="fileCategory">文件分类</param>
        /// <returns>文件相对地址</returns>
        protected virtual string GetFileRelativePath(string fileName, string filePath)
        {
            return Path.Combine(filePath, Path.GetFileName(fileName));
        }
    }
}